<html>

<head>
<title>Classes: ItemMotionHandler</title>
<style type="text/css"><!--tt { font-size: 10pt } pre { font-size: 10pt }--></style>
</head>

<body bgcolor="#ffffff" text="#000000" link="#000080" vlink="#800000" alink="#0000ff">

<table border="0" cellpadding="0" cellspacing="0" bgcolor="#d0d0d0">
  <tr>
    <td width="120" align="left"><a href="imgsave.html"><img width="96" height="20" border="0"
    src="../images/navlt.gif" alt="ImageSaver"></a></td>
    <td width="96" align="left"><a href="generic.html"><img width="64" height="20" border="0"
    src="../images/navrt.gif" alt="LayoutGeneric"></a></td>
    <td width="96" align="left"><a href="../classes.html"><img width="56" height="20"
    border="0" src="../images/navup.gif" alt="Classes"></a></td>
    <td width="288" align="right"><a href="../index.html"><img width="230" height="20"
    border="0" src="../images/proglw.gif" alt="Table of Contents"></a></td>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="600"><br>
    <h3>ItemMotionHandler<br>
    ItemMotionInterface</h3>
    <p><small><strong>Availability</strong>&nbsp; LightWave&reg; 6.0</small><br>
    <small><strong>Component</strong>&nbsp; Layout</small><br>
    <small><strong>Header</strong>&nbsp; <a href="../../include/lwmotion.h">lwmotion.h</a></small></p>
    <p>Motion handlers apply procedural translation, rotation and scaling to an item. They can
    be associated with any item in a scene that can be keyframed (objects, lights, cameras,
    bones).</p>
    <p><strong>Handler Activation Function</strong></p>
    <pre>   XCALL_( int ) MyItemMotion( long version, GlobalFunc *global,
      LWItemMotionHandler *local, void *serverData );</pre>
    <p>The <tt>local</tt> argument to a motion handler's activation function is an
    LWItemMotionHandler.</p>
    <pre>   typedef struct st_LWItemMotionHandler {
      LWInstanceFuncs *<strong>inst</strong>;
      LWItemFuncs     *<strong>item</strong>;
      void            (*<strong>evaluate</strong>)(LWInstance, const LWItemMotionAccess *);
      unsigned int    (*<strong>flags</strong>)   (LWInstance);
   } LWItemMotionHandler;</pre>
    <p>The first two members of this structure are standard <a href="../handler.html">handler
    functions</a>. The <tt>context</tt> argument to the <tt>inst-&gt;create</tt> function is
    the LWItemID of the item associated with this instance.</p>
    <p>In addition to the standard handler functions, a motion handler provides an evaluation
    function and a flags function.<dl>
      <dt><tt><strong>evaluate</strong>( instance, access )</tt></dt>
      <dd>This is where the motion handler does its work. LightWave&reg; calls the evaluation function
        at every point in the animation at which an item's motion parameters need to be
        calculated. The access structure, described below, tells you the item being animated and
        the frame and time of the evaluation, and provides functions to set motion parameters for
        the current time and to get the item's motion parameters for any time.</dd>
      <dt><br>
        <tt>f = <strong>flags</strong>( instance )</tt></dt>
      <dd>Returns an integer containing flags combined using bitwise-or. Currently the only flag
        is <tt>LWIMF_AFTERIK</tt>, which specifies that the plug-in will be evaluated after
        LightWave&reg; has performed the inverse kinematics calculations for the item.</dd>
    </dl>
    <p><strong>Interface Activation Function</strong></p>
    <pre>   XCALL_( int ) MyInterface( long version, GlobalFunc *global,
      LWInterface *local, void *serverData );</pre>
    <p>The interface activation's local data is the standard <a href="../handler.html#ui">interface</a>
    structure for handlers.</p>
    <p><strong>Motion Access</strong></p>
    <p>The evaluation function receives an LWItemMotionAccess structure. The data members are
    read-only. The functions provide the means to get and set motion parameters.</p>
    <pre>   typedef struct st_LWItemMotionAccess {
      LWItemID  <strong>item</strong>;
      LWFrame   <strong>frame</strong>;
      LWTime    <strong>time</strong>;
      void     (*<strong>getParam</strong>) (LWItemParam, LWTime, LWDVector);
      void     (*<strong>setParam</strong>) (LWItemParam, const LWDVector);
   } LWItemMotionAccess;</pre>
    <dl>
      <dt><strong><tt>item</tt></strong></dt>
      <dd>The ID for the item to be affected by the procedural motion.</dd>
      <dt><tt><br>
        <strong>frame</strong></tt></dt>
      <dd>The frame number at which the motion should be evaluated.</dd>
      <dt><tt><br>
        <strong>time</strong></tt></dt>
      <dd>The animation time for which the motion should be evaluated.</dd>
      <dt><tt><br>
        <strong>getParam</strong>( param, lwtime, vec )</tt></dt>
      <dd>Returns a motion parameter for the item at any given time. Only the <tt>LWIP_POSITION</tt>,
        <tt>LWIP_ROTATION</tt> and <tt>LWIP_SCALING</tt> parameters may be queried.</dd>
      <dt><tt><br>
        <strong>setParam</strong>( param, vec )</tt></dt>
      <dd>Used by the evaluation function to set the computed motion of the item at the current
        time. Only the <tt>LWIP_POSITION</tt>, <tt>LWIP_ROTATION</tt> and <tt>LWIP_SCALING</tt>
        parameters may be set.</dd>
    </dl>
    <p><strong>Example</strong></p>
    <p>If you want to modify an item's motion, rather than completely replace it, call <tt>getParam</tt>
    for the current time to find out what the item's unmodified motion would be, then
    calculate a new motion based on that and call <tt>setParam</tt>.</p>
    <pre>   XCALL_( static void )
   Evaluate( MyInstance *inst, const LWItemMotionAccess *access )
   {
      LWDVector pos;

      access-&gt;getParam( LWIP_POSITION, access-&gt;time, pos );
      ...do something to pos[]...
      access-&gt;setParam( LWIP_POSITION, pos );
   }</pre>
    <p>The <a href="../../sample/Layout/ItemMotion/kepler/">kepler</a> sample is a motion handler that moves an
    item in an elliptical orbit</td>
  </tr>
</table>
</body>
</html>
